const express = require('express');
const router = express.Router();
const path = require('path');
const promisify = require('util').promisify;
const readdir = promisify(require('fs').readdir);

/* GET home page. */


module.exports = roomController => {
  return router.get('/', (req, res, next) => readdir(path.join('public', 'videos'))
    .then(demos => res.render('index', {
      title: 'iJuli',
      rooms: roomController.getRooms(),
      demos
    }))
    .catch(e => console.log(e))
  );
};
